import 'package:flutter/material.dart';
import 'package:gold/app/user_provider.dart';
import 'package:gold/base/provider_scaffold.dart';
import 'package:gold/ui/my/settings/avatar/avatar_viewmodel.dart';
import 'package:gold/utils/res.dart';
import 'package:gold/utils/xfg_color.dart';
import 'package:gold/utils/xfg_size.dart';
import 'package:gold/widgets/common_widgets.dart';
import 'package:gold/widgets/http_image.dart';
import 'package:gold/widgets/xfg_text.dart';
import 'package:provider/provider.dart';

/// @description: 修改头像
/// @author tangzhentao
/// @created at 21:11 2025/1/1

class AvatarPage extends StatelessWidget {
  const AvatarPage({super.key});

  @override
  Widget build(BuildContext context) {
    return ProviderScaffold<AvatarViewmodel>(
      appBar: (_) => xfgAppbar(title: '修改头像'),
      model: AvatarViewmodel(),
      builder: (ctx, avatar) => Column(
        children: [
          strokeHeightContainer,
          Container(
            margin: EdgeInsets.only(top: XfgSize().size76, bottom: XfgSize().size82),
            child: HttpImage(ctx.read<UserProvider>().user.avatar, size: Size.square(XfgSize().size76), placeholder: Res.imagesAvatar, radius: BorderRadius.circular(XfgSize().size76)),
          ),
          TextButton(
            onPressed: avatar.uploadAvatar,
            style: xfgButtonStyle(Size(XfgSize().size342, XfgSize().size50), radius: XfgSize().size50),
            child: XfgText('上传头像', color: XfgColor.white, fontSize: XfgSize().text20),
          ),
          SizedBox(height: XfgSize().size22),
          XfgText('图片格式jpg、png、jpeg,大小不超过10MB', fontSize: XfgSize().text14, color: XfgColor.text3)
        ],
      ),
    );
  }

}
